package com.cooper.scheduler.job;

import org.apache.commons.lang.StringUtils;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import com.cooper.resource.IResourceManager;

/**
 * ResourceManager执行定时刷新的任务
* @Description: 
* @version: v1.0.0
* @author: coral coraldane@163.com
* @date: Jan 15, 2015 11:14:32 PM
*
* Modification History:
*  Date              Author          Version            Description
*-------------------------------------------------------------------*
* Jan 15, 2015      coraldane        v1.0.0
 */
public class ResourceManagerRunningJob implements Job {
	
	@Autowired
	private IResourceManager resourceManager;

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		// TODO Auto-generated method stub
		JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
		String itemName = jobDataMap.getString("itemName");
		if(StringUtils.isNotBlank(itemName)){
			try {
				this.resourceManager.refresh(itemName);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

}
